#!/usr/bin/perl -w

# cutfold
# File ID: d8de5ac8-5d37-11df-a137-90e6ba3022ac
# Inserts “CUT” marks with Vim fold before and after stdin.
# Select text in visual line mode and filter the block through this script.

use strict;

$| = 1;

my $Line = <STDIN>;
my ($Indent, $Title) = ("", "CUT");

defined($ARGV[0]) && ($Title = join(" ", @ARGV));
$Line =~ /^(\s+)/ && ($Indent = $1);
print("======== $Title \x7B\x7B\x7B ========\n$Line");

while (<STDIN>) {
	print($_);
}

print("======== \x7D\x7D\x7D $Title ========\n");
